/**
 *
 * Copyright 2015 RSVP Technologies Inc. All rights reserved.
 * TransitStep.java
 *
 */
package com.gfinal.map.direction;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.gfinal.map.place.Location;

/**
 * 公交分段
 *@author Gao Yudong (gyd@nbicc.com) 
 *@date 2015-3-2
 */
public class TransitStep implements Serializable {
	private static final long serialVersionUID = -867998219442109897L;

	/**
	 * 路段距离
	 */
	private int distance = 0;
	
	/**
	 * 路段耗时
	 */
	private int duration = 0;
	
	/**
	 * 路段类型
	 */
	private int type = 0;
	
	/**
	 * 路段起点经纬度
	 */
	private Location stepOriginLocation = null;
	
	/**
	 * 路段终点经纬度
	 */
	private Location stepDestinationLocation = null;
	
	/**
	 * 路段说明
	 */
	private String stepInstruction = null;
	
	/**
	 * 路段位置坐标描述
	 */
	private String path = null;
	
	public TransitStep() {
		super();
	}

	public int getDistance() {
		return distance;
	}

	public void setDistance(int distance) {
		this.distance = distance;
	}

	public int getDuration() {
		return duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public Location getStepOriginLocation() {
		return stepOriginLocation;
	}

	public void setStepOriginLocation(Location stepOriginLocation) {
		this.stepOriginLocation = stepOriginLocation;
	}

	public Location getStepDestinationLocation() {
		return stepDestinationLocation;
	}

	public void setStepDestinationLocation(Location stepDestinationLocation) {
		this.stepDestinationLocation = stepDestinationLocation;
	}

	public String getStepInstruction() {
		if(stepInstruction != null) {
			String regEx_html = "<[^>]+>";
			Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
			Matcher m_html = p_html.matcher(stepInstruction);
			stepInstruction = m_html.replaceAll("");
		}
		return stepInstruction;
	}

	public void setStepInstruction(String stepInstruction) {
		this.stepInstruction = stepInstruction;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	
	@Override
	public String toString() {
		return "TransitStep [distance=" + distance + ", duration=" + duration
				+ ", type=" + type + ", stepOriginLocation="
				+ stepOriginLocation + ", stepDestinationLocation="
				+ stepDestinationLocation + ", stepInstruction="
				+ getStepInstruction() + "]";
	}

	class Vehicle implements Serializable {
		private static final long serialVersionUID = -2259861950054737963L;
		
		/**
		 * 起点站
		 */
		private String start_name = null;
		
		/**
		 * 终点站
		 */
		private String end_name = null;
		
		/**
		 * 首班车时间
		 */
		private String start_time = null;
		
		/**
		 * 末班车时间
		 */
		private String end_time = null;
		
		private String start_uid = null;
		
		private String end_uid = null;
		
		private String uid = null;
		
		/**
		 * 线路名
		 */
		private String name = null;
		
		/**
		 * 经过几站
		 */
		private int stop_num = 0;
		
		/**
		 * 总票价
		 */
		private int total_price = 0;
		
		/**
		 * 公交线路类型
		 */
		private int type = 0;
		
		/**
		 * 区间价
		 */
		private int zone_price = 0;

		public Vehicle() {
			super();
		}

		public String getStart_name() {
			return start_name;
		}

		public void setStart_name(String start_name) {
			this.start_name = start_name;
		}

		public String getEnd_name() {
			return end_name;
		}

		public void setEnd_name(String end_name) {
			this.end_name = end_name;
		}

		public String getStart_time() {
			return start_time;
		}

		public void setStart_time(String start_time) {
			this.start_time = start_time;
		}

		public String getEnd_time() {
			return end_time;
		}

		public void setEnd_time(String end_time) {
			this.end_time = end_time;
		}

		public String getStart_uid() {
			return start_uid;
		}

		public void setStart_uid(String start_uid) {
			this.start_uid = start_uid;
		}

		public String getEnd_uid() {
			return end_uid;
		}

		public void setEnd_uid(String end_uid) {
			this.end_uid = end_uid;
		}

		public String getUid() {
			return uid;
		}

		public void setUid(String uid) {
			this.uid = uid;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public int getStop_num() {
			return stop_num;
		}

		public void setStop_num(int stop_num) {
			this.stop_num = stop_num;
		}

		public int getTotal_price() {
			return total_price;
		}

		public void setTotal_price(int total_price) {
			this.total_price = total_price;
		}

		public int getType() {
			return type;
		}

		public void setType(int type) {
			this.type = type;
		}

		public int getZone_price() {
			return zone_price;
		}

		public void setZone_price(int zone_price) {
			this.zone_price = zone_price;
		}

		@Override
		public String toString() {
			return "Vehicle [start_name=" + start_name + ", end_name="
					+ end_name + ", start_time=" + start_time + ", end_time="
					+ end_time + ", start_uid=" + start_uid + ", end_uid="
					+ end_uid + ", uid=" + uid + ", name=" + name
					+ ", stop_num=" + stop_num + ", total_price=" + total_price
					+ ", type=" + type + ", zone_price=" + zone_price + "]";
		}
		
	}
}
